#include "mailbox_page.h"




as::md::MailBoxPage::MailBoxPage()
{
	for (int i = 0; i < MAX_MAIL_BOX_COUNT; ++i)
	{
		idle_index_.insert(i);
		mailboxs_.push_back(nullptr);
	}
}

void as::md::MailBoxPage::RecycleMailbox(int index)
{
	if (index < 0 || index > MAX_MAIL_BOX_COUNT)
		return;

	auto it = idle_index_.find(index);
	if (it != idle_index_.end())
	{
		return;
	}

	idle_index_.insert(index);
	mailboxs_[index].reset();
}

as::md::MailBoxPtr as::md::MailBoxPage::GetMailBox(int index)
{
	if (index < 0 || index > MAX_MAIL_BOX_COUNT)
		return nullptr;
	return mailboxs_[index];
}

